package demo150;

public class merge{
        public void merge(int[] nums1, int m, int[] nums2, int n) {
            int[] s=  new int[m+n];
            int t = 0;
            int i = 0;
            int j = 0;
            while(i < m && j < n) {
                if(nums1[i] < nums2[j]) {
                    s[t++] = nums1[i++];
                }else {
                    s[t++] = nums2[j++];
                }
            }
            while(i < m) {
                s[t++] = nums1[i++];
            }
            while(j < n) {
                s[t++] = nums2[j++];
            }
            i = 0;
            for(int x:s){
                nums1[i++] = x;
            }
        }
}
